package cn.webrx.coll;/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */

import java.util.HashSet;
import java.util.List;
import java.util.TreeSet;

/**
 * <p>Project: jse2204 - cn.webrx.coll.TreeSet1
 * <p>Powered by webrx On 2022-09-19 16:33:04
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class TreeSet1 {
    public static void main(String[] args) {

        TreeSet<Integer> tset = new TreeSet<>();
        tset.add(6);
        tset.add(10);
        tset.add(1);
        tset.add(5);
        tset.add(5);
        tset.add(5);
        tset.add(5);
        tset.add(5);
        tset.add(2);
        System.out.println(tset);


        HashSet<User> set1 = new HashSet<>(List.of(
                new User(1, "李四",60),
                new User(2, "张三",35),
                new User(3, "王五",78),
                new User(1, "王五",55),
                new User(2, "王五",98)
        ));
        User u = new User(4,"王五",54);
        //System.out.println(u);
        set1.add(u);
        System.out.println(set1.size());
        System.out.println(set1);


        //cn.webrx.coll.User 降序
        TreeSet<User> tset1 = new TreeSet<>((a,b)->b.getScore()-a.getScore());
        tset1.add(new User(6,"张三",90));
        tset1.add(new User(2,"张三",30));
        tset1.add(new User(1,"李强",60));
        System.out.println(tset1);

    }
}
